/**
 * 排列组合
 */


let permutation = {

    /**
     *
     * 相当于 Cn1 + Cn2 + Cn3 + ... + Cnn
     * example:
     *      let data = ['a','b','c','d'];
     console.log(permutation.getGroup(data));

     [ 'a',
     'b',
     'ab',
     'c',
     'ac',
     'bc',
     'abc',
     'd',
     'ad',
     'bd',
     'abd',
     'cd',
     'acd',
     'bcd',
     'abcd' ]

     * @param data
     * @param index
     * @param group
     * @return {*}
     */
    getGroup(data, index = 0, group = []) {
        let need_apply = [];
        need_apply.push(data[index]);
        for (let i = 0; i < group.length; i++) {
            need_apply.push(group[i] + data[index]);
        }
        group.push(...need_apply);
        if (index + 1 >= data.length) {
            return group;
        } else {
            return this.getGroup(data, index + 1, group);
        }
    },


    perm(testArr){

    },


};

export default permutation;




